﻿using Simulation.Framework;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using TMPro;

namespace Easy.Game2d {

    public partial class UIPagePanel : PanelBase {

        #region override
        public override void Init(params object[]  data) {
            InitComponent();
        }

        public override void Clear() {
            ClearComponent();
        }

        public override void Open() {
            gameObject.SetActive(true);
        }

        public override void Close() {
            gameObject.SetActive(false);
        }
        #endregion

        #region data
        public int hpvalue = 0;//命魂补剂
        public int doupeng = 0;//幽魂斗篷
        public int mozhang = 0;//魔杖
        #endregion

        #region btn
        private void OnBtnshanghaiButtonClicked()
        {
            if (mozhang > 0) { mozhang--; btnshanghaiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = mozhang.ToString(); EventUtil.DispatchEvent(EventData.AddDamage, 1); }
        }

        private void OnBtnxueliangButtonClicked()
        {
            if (hpvalue > 0) { hpvalue--; btnxueliangButton.transform.GetChild(0).GetComponent<TMP_Text>().text = hpvalue.ToString(); EventUtil.DispatchEvent(EventData.AddKouXueClick, -20); }
        }

        private void OnBtndoupengButtonClicked()
        {
            if (doupeng > 0)
            {
                doupeng--;
                btndoupengButton.transform.GetChild(0).GetComponent<TMP_Text>().text = doupeng.ToString();
                EventUtil.DispatchEvent(EventData.AddHPClick, 10);
                EventUtil.DispatchEvent(EventData.AddKouXueClick, -10);               
            }
        }
        private void OnBtnOFFButtonClicked()
        {
            Time.timeScale = 1;
            Close();
        }
        #endregion

        #region logic
        public void OnshanghaiButtonClicked()
        {
            mozhang += 1;
            btnshanghaiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = mozhang.ToString();
        }

        public void OnxueliangButtonClicked()
        {
            hpvalue += 1;
            btnxueliangButton.transform.GetChild(0).GetComponent<TMP_Text>().text = hpvalue.ToString();
        }

        public void OndoupengButtonClicked()
        {
            doupeng += 1;
            btndoupengButton.transform.GetChild(0).GetComponent<TMP_Text>().text = doupeng.ToString();
        }
        #endregion
    }
}
